package com.example.springbott.wx_controller;

import com.example.springbott.bean.BaseRespVo;
import com.example.springbott.bean.MarketUser;
import com.example.springbott.bean.common.BasePageInfo;
import com.example.springbott.bean.common.CommonData;
import com.example.springbott.bean.silic.FootprintIdBo;
import com.example.springbott.bean.silic.MarketGoodsListVo;
import com.example.springbott.wx_service.WXFootprintService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *  足迹
 *
 * @author silic xia
 * @since 2022/11/22 15:23
 */

@RestController
@RequestMapping("wx/footprint")
public class WXFootprintController {

    @Autowired
    WXFootprintService wxFootprintService;


    /**
     *  list
     *
     * @param /wx/footprint/list?page=1&limit=10
     * @return BaseRespVo--CommonData--MarketGoodsListVo
     * @author silic xia
     * @since 2022/11/22 15:24
     */
    @RequestMapping("list")
    public BaseRespVo wxFootprintList(BasePageInfo info){
        MarketUser user = (MarketUser) SecurityUtils.getSubject().getPrincipal();
        CommonData<MarketGoodsListVo> data = wxFootprintService.wxFootprintList(info,user.getId());
        return BaseRespVo.ok(data);
    }


    /**
     *  delete
     *
     * @param /{"id":198}
     * @return {"errno":0,"errmsg":"成功"}
     * @author silic xia
     * @since 2022/11/22 15:24
     */
    @RequestMapping("delete")
    public BaseRespVo wxFootprintDelete(@RequestBody FootprintIdBo footprintIdBo){
        MarketUser user = (MarketUser) SecurityUtils.getSubject().getPrincipal();
        wxFootprintService.wxFootprintDelete(footprintIdBo.getId(),user.getId());
        return BaseRespVo.ok();
    }

}

